package com.ruoyi.driver.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.driver.domain.CarownerVehiclelengh;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.driver.service.ICarownerVehiclelenghService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆长度Controller
 * 
 * @author Wevon
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/driver/vehiclelengh")
public class CarownerVehiclelenghController extends BaseController
{
    @Autowired
    private ICarownerVehiclelenghService carownerVehiclelenghService;

    /**
     * 查询车辆长度列表
     */
    @PreAuthorize("@ss.hasPermi('driver:vehiclelengh:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarownerVehiclelengh carownerVehiclelengh)
    {
        startPage();
        List<CarownerVehiclelengh> list = carownerVehiclelenghService.selectCarownerVehiclelenghList(carownerVehiclelengh);
        return getDataTable(list);
    }

    /**
     * 导出车辆长度列表
     */
    @PreAuthorize("@ss.hasPermi('driver:vehiclelengh:export')")
    @Log(title = "车辆长度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarownerVehiclelengh carownerVehiclelengh)
    {
        List<CarownerVehiclelengh> list = carownerVehiclelenghService.selectCarownerVehiclelenghList(carownerVehiclelengh);
        ExcelUtil<CarownerVehiclelengh> util = new ExcelUtil<CarownerVehiclelengh>(CarownerVehiclelengh.class);
        util.exportExcel(response, list, "车辆长度数据");
    }

    /**
     * 获取车辆长度详细信息
     */
    @PreAuthorize("@ss.hasPermi('driver:vehiclelengh:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(carownerVehiclelenghService.selectCarownerVehiclelenghById(id));
    }

    /**
     * 新增车辆长度
     */
    @PreAuthorize("@ss.hasPermi('driver:vehiclelengh:add')")
    @Log(title = "车辆长度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarownerVehiclelengh carownerVehiclelengh)
    {
        return toAjax(carownerVehiclelenghService.insertCarownerVehiclelengh(carownerVehiclelengh));
    }

    /**
     * 修改车辆长度
     */
    @PreAuthorize("@ss.hasPermi('driver:vehiclelengh:edit')")
    @Log(title = "车辆长度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarownerVehiclelengh carownerVehiclelengh)
    {
        return toAjax(carownerVehiclelenghService.updateCarownerVehiclelengh(carownerVehiclelengh));
    }

    /**
     * 删除车辆长度
     */
    @PreAuthorize("@ss.hasPermi('driver:vehiclelengh:remove')")
    @Log(title = "车辆长度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(carownerVehiclelenghService.deleteCarownerVehiclelenghByIds(ids));
    }
}
